/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufsc.aps.jogodavida.view;

import br.ufsc.aps.jogodavida.model.Carta;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.JLabel;

/**
 *
 * @author gustavo
 */
public class LabelCarta extends JLabel {
    
    protected Carta carta = null;
    protected boolean isBig;

    public Carta getCarta() {
        return carta;
    }
    
    public LabelCarta(Carta carta,boolean isBig) {
        this.carta = carta;
        if(isBig) {
            this.setPreferredSize(new Dimension(110,130));
            this.setMinimumSize(new Dimension(110, 130));
            this.setMaximumSize(new Dimension(110, 130));
            this.setFont(new Font("TAHOMA", Font.BOLD, 10));
            this.setHorizontalTextPosition(JLabel.CENTER);
            this.setVerticalTextPosition(JLabel.CENTER);
            this.setOpaque(true);
            this.setBackground(carta.getTipoConjunto().getCor());
            this.setBorder(BorderFactory.createLineBorder(Color.GRAY,1));
            
            String text = "<html>"
                    + "<p align=\"left\">" + carta.getNaipe() + "</p>"
            + "<br/><p align=\"center\">" + carta.getDescricao() + "</p>"
            + "<br/><p align=\"right\">" + carta.getPontuacao() + "</p></html>";
            
            this.setText(text);
        }
        else {
            this.setPreferredSize(new Dimension(30,20));
            this.setMinimumSize(new Dimension(30,25));
            this.setMaximumSize(new Dimension(30,25));
            this.setFont(new Font("TAHOMA", Font.BOLD, 11));
            this.setHorizontalTextPosition(JLabel.CENTER);
            this.setVerticalTextPosition(JLabel.CENTER);
            this.setOpaque(true);
            this.setBackground(carta.getTipoConjunto().getCor());
            this.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/ufsc/aps/jogodavida/view/" + carta.getTipoConjunto().getIcone())));
            this.setBorder(BorderFactory.createLineBorder(Color.GRAY,1));
            this.setToolTipText(carta.getDescricao());
            String text = "<html>"
                    + "<p align=\"center\">" + carta.getNaipe() + " - " + carta.getPontuacao() + "</p></html>";
            this.setText(text);
        }
    }
}
